<?php get_header();?>
<?php 
$theme_options = get_option('po_theme');
// If Portfolio tab disabled => the $p=0
if ($theme_options['enable_portfolio']== "enable") {$p = $theme_options['portfolio_cat'];}
else {$p = 0;}
?>
<?php if (have_posts()) : while (have_posts()) : the_post(); 
		// GET CUSTOM SIDEBAR
		$sidebar = get_post_meta($post->ID, 'sidebar_value', true);
?>
	<div id="content"<?php if (in_category($p)) {echo"class=\"cfull\"";} ?>>
	<div id="cc">
		<div id="bread">
			<div id="breadbox">
				<?php // BREADCRUMBS
					if (function_exists('yoast_breadcrumb')) {yoast_breadcrumb('<div id="breadcrumbs">','</div>');}
				?>
				<div class="clear"><!-- --></div>
			</div><!-- end breadbox -->
		</div>
		<div id="contentbox" class="<?php if (in_category($p)) {echo'wfull';} else {echo'w620';} ?>">

		<div id="title">
			<h1 class="<?php if (in_category($p)) {echo'bline';} else {echo'noline';} ?>"><?php the_title(); ?></h1>
			<?php if (!(in_category($p))) { ?>
			<div class="po"><span class="tim"><?php the_time('M jS, Y'); ?></span><span class="com"><?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?></span></div>
			<?php } ?>
		</div><!-- end title -->

			<?php the_content(); ?>

			<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>

			<?php if (!(in_category($p))) { ?>
			<div id="share">
				<a class="tooltip" title="Tweet this post" href="http://twitter.com/home?status=Currently reading <?php the_permalink(); ?>"><img src="<?php bloginfo('template_url'); ?>/images/icons/twitter_16.png" alt=""/></a>
				<a class="tooltip" title="Post to Facebook" href="http://www.facebook.com/sharer.php?u=<?php the_permalink();?>&t=<?php the_title(); ?>"><img src="<?php bloginfo('template_url'); ?>/images/icons/facebook_16.png" alt=""/></a>
				<a class="tooltip" title="Digg this!" href="http://www.digg.com/submit?phase=2&url=<?php the_permalink();?>"><img src="<?php bloginfo('template_url'); ?>/images/icons/digg_16.png" alt=""/></a>
				<a class="tooltip" title="Share on Reddit" href="http://www.reddit.com/submit?url=<?php the_permalink();?>&title=<?php the_title(); ?>"><img src="<?php bloginfo('template_url'); ?>/images/icons/reddit_16.png" alt=""/></a>
				<a class="tooltip" title="Add to Delicious" href="http://del.icio.us/post?url=<?php the_permalink() ?>&title=<?php echo urlencode(the_title('','', false)) ?>"><img src="<?php bloginfo('template_url'); ?>/images/icons/delicious_16.png" alt=""/></a>
				<a class="tooltip" title="Stumble this!" href="http://www.stumbleupon.com/submit?url=<?php the_permalink() ?>&title=<?php echo urlencode(the_title('','', false)) ?>"><img src="<?php bloginfo('template_url'); ?>/images/icons/stumbleupon_16.png" alt=""/></a>
				<a class="tooltip" title="Google Buzz" href="http://www.google.com/reader/link?title=<?php the_title(); ?>&url=<?php the_permalink() ?>"><img src="<?php bloginfo('template_url'); ?>/images/icons/googlebuzz_16.png" alt=""/></a>
				<a class="tooltip" title="Yahoo Buzz" href="http://buzz.yahoo.com/submit/?submitUrl=<?php the_permalink() ?>&submitHeadline=<?php the_title(); ?>"><img src="<?php bloginfo('template_url'); ?>/images/icons/yahoobuzz_16.png" alt=""/></a>
				<a class="tooltip" title="Post to Technorati" href="http://technorati.com/signup/?f=favorites&Url=<?php the_permalink() ?>"><img src="<?php bloginfo('template_url'); ?>/images/icons/technorati_16.png" alt=""/></a>
				<a class="tooltip" title="Share on Linkedin" href="http://www.linkedin.com/shareArticle?mini=true&url=<?php the_permalink() ?>&title=<?php the_title(); ?>&source="><img src="<?php bloginfo('template_url'); ?>/images/icons/linkedin_16.png" alt=""/></a>
				<a class="tooltip" title="Email a friend" href="mailto:EMAIL ADDRESS?body=<?php the_permalink();?>"><img src="<?php bloginfo('template_url'); ?>/images/icons/email_16.png" alt=""/></a>
				<div class="clear"><!-- --></div>
			</div>
			<div class="m"><?php the_tags('<span class="tag"> ', ', ', '</span>'); ?><span class="cat"><?php the_category(', ') ?></span></div>
			<?php } ?>

			<?php //AUTHOR INFO
			if ($theme_options['enable_author_info']== "enable") { ?>
				<div class="author <?php if (in_category($p)) {echo "ai1";} else {echo "ai2";} ?>">
				<div id="ava"><?php echo get_avatar( get_the_author_meta('user_email'), '55' );?></div>
				<strong>About author:</strong>
				<p><?php the_author_description();?></p>
				</div>
			<?php } ?>

			<div class="clear tline h10 relative"><!-- --></div>
	
			<?php comments_template(); ?>

			<?php endwhile; else: ?>
			<div id="contentbox" class="w620">
			<div id="title">
			<h1 class="bline">404</h1>
			</div><!-- end title -->
			<p>Sorry, no posts matched your criteria.</p>
			<?php endif; ?>

			<?php //INCLUDE SIDEBAR IF IT IS NOT PORTFOLIO POST
				$end_of_contentbox = '</div>';
				$before = '<ul id="sidebar">';
				$after = '</ul>';
				$before2 = '<div id="spbox"><div id="spa"></div><ul id="sidebar" class="p">';
				$after2 = '</ul><div class="clear"></div><div id="spb"></div></div>';
			if (!(in_category($p))) {
				// DISPLAY CUSTOM SIDEBAR
				if ($sidebar) { echo $end_of_contentbox; echo $before; if ( function_exists('dynamic_sidebar') && dynamic_sidebar($sidebar)); echo $after;}
				else { echo $end_of_contentbox; echo $before; if (function_exists('dynamic_sidebar') && dynamic_sidebar('Default Sidebar')); echo $after;}
				// DISPLAY PORTFOLIO SIDEBAR
			} else { echo $before2; if (function_exists('dynamic_sidebar') && dynamic_sidebar('Portfolio Sidebar')); echo $after2; echo $end_of_contentbox;}
			?>

<?php get_footer(); ?>
